﻿@using Masa.BuildingBlocks.StackSdks.Config;
@using Masa.Contrib.StackSdks.Config;
@inherits LayoutComponentBase
@inject GlobalConfig GlobalConfig
@inject NavigationManager Navigation
@inject IMasaStackConfig MasaStackConfig

<SLayout AppId="@MasaStackConfig.GetWebId(MasaStackConstant.ALERT)" OnSignOut="SignOut" OnErrorAsync="OnError"
         Logo="https://cdn.masastack.com/stack/images/logo/MASAStack/logo-h-en.png"
         MiniLogo="https://cdn.masastack.com/stack/images/logo/MASAStack/logo.png"
         WhiteUris="WhiteUris" Exact="false">
    @Body
    <MLoading />
</SLayout>

@code {
    [Inject]
    public IPopupService PopupService { get; set; } = default!;

    private List<string> WhiteUris = new List<string> { "alarmHistory/*" };

    private Task OnError(Exception exception)
    {
        PopupService.EnqueueSnackbarAsync(exception.Message, AlertTypes.Error);
        GlobalConfig.Loading = false;
        GlobalConfig.ThrottleFlag = false;
        return Task.CompletedTask;
    }

    private bool SignOut()
    {
        Navigation.NavigateTo("/Logout", true);
        return true;
    }
}